#include <iostream>
#include <thread>

using std::cout;
using std::endl;
using std::thread;

int gCnt = 1;//全局变量

void threadFuncA()
{
    gCnt = 10;
    cout << "thread A gCnt = " << gCnt << endl;
}

void threadFuncB()
{
    gCnt = 20;
    cout << "thread B gCnt = " << gCnt << endl;
}

int main(int argc, char *argv[])
{
    cout << "main thread begin gCnt = " << gCnt << endl;

    thread thA(threadFuncA);
    thread thB(threadFuncB);

    thA.join();
    thB.join();
    cout << "main thread end gCnt = " << gCnt << endl;

    return 0;
}

